home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
031-040
/
amok31
/
task&process
/
task.mod
< prev
next >
Wrap
Text File
|
1993-11-04
|
3KB
|
103 lines
(*---------------------------------------------------------------------------
:Program. Task.mod
:Contants. Start Procedure as Task
:Remark. Ported from C to Modula-2
:History. C-Edition by Arno Gölzer
:History. V1.0, M. Peuckert, having spent a lot of time meditating
:History. V2.0, M. Peuckert, November 89
:Author. Markus Peuckert
:Address. Schützenstr. 50, D-3550 Marburg, West-Germany,
:Copyright. PD
:Language. Modula-2
:Translator. M2Amiga V3.2d
---------------------------------------------------------------------------*)
MODULE Task;
FROM SYSTEM IMPORT ADR,ADDRESS,INLINE;
FROM Arts IMPORT Assert,TermProcedure,CurrentLevel;
FROM Graphics IMPORT RastPortPtr, Move, Text, SetAPen, RectFill, DrawEllipse;
FROM Intuition IMPORT IDCMPFlags, IDCMPFlagSet, ScreenFlags, ScreenFlagSet,
WindowFlags, WindowFlagSet, WindowPtr, CloseWindow,
IntuiMessagePtr;
FROM Dos IMPORT Delay;
FROM Exec IMPORT GetMsg, ReplyMsg, WaitPort, TaskPtr, PutMsg, FindTask;
FROM ExecSupport IMPORT CreateTask, DeleteTask;
FROM Terminal IMPORT WriteString, WriteLn, waitCloseGadget;
FROM IntuiSup IMPORT CreateWindow, ActivWindow;
CONST TName = "NewTask";
VAR win, Cwin : WindowPtr;
rp, Crp : RastPortPtr;
Level : INTEGER;
TaskP : TaskPtr;
TMsg : IntuiMessagePtr;
a : INTEGER;
PROCEDURE Cleanup;
BEGIN
IF Level >= CurrentLevel () THEN
TaskP := FindTask (ADR(TName));
IF TaskP#NIL THEN
DeleteTask (ADR(TaskP));
WHILE TaskP#NIL DO TaskP := FindTask (ADR(TName)) END
END;
IF win#NIL THEN CloseWindow (win) END;
END
END Cleanup;
PROCEDURE Function;
VAR i, x, y : INTEGER;
BEGIN
LOOP
WaitPort (win^.userPort); TMsg := GetMsg (win^.userPort);
SetAPen (rp, a);
Move (rp, a*5,140); Text (rp, ADR("Funcky"), 6);
FOR i:=0 TO 100 DO RectFill (rp, x, y, x+2*i, y+i) END;
INC (x, 20); INC (y, 10);
IF a>=3 THEN EXIT END
END
END Function;
VAR i : INTEGER;
BEGIN
win:=NIL; waitCloseGadget:=FALSE;
Level:=CurrentLevel(); TermProcedure(Cleanup);
Cwin := ActivWindow();
Crp := Cwin^.rPort;
win:=CreateWindow(300,15,256, 160, IDCMPFlagSet{mouseButtons},
WindowFlagSet{borderless}, NIL,NIL,NIL,
ScreenFlagSet{wbenchScreen});
Assert(win#NIL,ADR("Kann Fenster nicht öffnen"));
rp:=win^.rPort;
(*--------------- Initialisierung abgeschlossen ----------------------------*)
TaskP := NIL; TMsg := NIL;
WriteString ("Aktiviere SubTask ..."); WriteLn;
TaskP := CreateTask (ADR(TName), 0, ADR(Function), 8000);
(* Ab hier läuft der Task eigenständig *)
Assert (TaskP#NIL, ADR("Kein Task"));
win^.userPort^.sigTask := TaskP;
FOR a:=1 TO 3 DO
PutMsg (win^.userPort, ADR(TMsg)); (* Msg weckt den Task *)
WriteString ("Noch ein Aufruf"); WriteLn;
FOR i:=0 TO 50 BY 4 DO
SetAPen (Crp, a);
DrawEllipse (Crp, 132,90,2*i+2*a, i+a);
Delay (1)
END
END;
Delay (100);
WriteString ("Beende SubTask ...");
END Task.